package com.stillalive.blogsystem.pojo.response;

import com.stillalive.blogsystem.enums.ResultCodeEnum;
import lombok.Data;

@Data
public class Result {
    // 业务状态码
    private ResultCodeEnum code;
    private String errMsg;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.SUCCESS);
        result.setData(data);
        return result;
    }
    public static Result fail(String errMsg) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setErrMsg(errMsg);
        return result;
    }
    public static Result fail(String errMsg, Object data) {
        Result result = new Result();
        result.setCode(ResultCodeEnum.FAIL);
        result.setData(data);
        result.setErrMsg(errMsg);
        return result;
    }
}
